package io.gitee.hechenl.datamultitrans.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Configuration
@EnableScheduling
public class SchedulerConfig {

    @Bean
    public ThreadPoolTaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setPoolSize(5); // 设置线程池大小（默认1）
        scheduler.setThreadNamePrefix("data-transfer-task-"); // 线程名前缀
        scheduler.setAwaitTerminationSeconds(60); // 等待任务完成的最大时间（秒）
        scheduler.setWaitForTasksToCompleteOnShutdown(true);
        return scheduler;
    }

}
